<?php

namespace helper;


class TpConfig {

    /**
     * 获取配置参数
     * @param $name
     * @return mixed
     */
    static public function getConfig($name) {
        return config($name);
    }

    /**
     * 设置参数
     * @param $name
     * @param $arr
     * @return bool
     */
    static public function setConfig($name, $arr) {
        $path = app()->getConfigPath() . $name . '.php';
        $arr = Arr::arr2export($arr);
        $content = <<<EOT
<?php
return $arr;
EOT;
        return file_put_contents($path, $content);
    }

    /**
     * 追加设置
     * @param $name
     * @param $append
     * @return false|int
     */
    static public function appendConfig($name,$append){
        $path = app()->getConfigPath() . $name . '.php';
        $arr = Arr::arr2export(array_merge(config($name),$append));
        $content = <<<EOT
<?php
return $arr;
EOT;
        return file_put_contents($path, $content);
    }

}